/*
* 外界必须传进的支付通道类型模型
* */
import 'abs_four_channel.dart';
import 'abs_third_channel.dart';

class AbsPayChannel {
  /// 渠道类型（1=第三方渠道，2=第四方渠道）
  final int? channelType;

  /// 支付参数结果集。第四方支付时，服务器会返回此数据，第四方支付直接使用此模型（可直接唤醒支付）
  final AbsPayParamsChannel? payParamsChannel;

  /// 第三方通道结果集
  final List<AbsThirdChannel> thirdChannel;

  AbsPayChannel({
    this.channelType,
    this.thirdChannel = const <AbsThirdChannel>[],
    this.payParamsChannel,
  });

  factory AbsPayChannel.fromMap(Map<String, dynamic> json) {
    List<AbsThirdChannel> list = json['thirdChannel'] == null
        ? []
        : List<AbsThirdChannel>.from(
            json['thirdChannel'].map((x) => AbsThirdChannel.fromMap(x)),
          );

    return AbsPayChannel(
      channelType: json['channelType'],
      payParamsChannel: json['fourChannle'] == null ? null : AbsPayParamsChannel.fromMap(json['fourChannle']),
      thirdChannel: list,
    );
  }

  Map<String, dynamic> toMap() => {
        'channelType': channelType,
        'payParamsChannel': payParamsChannel,
        'thirdChannel': thirdChannel,
      };
}
